
include( "shared.lua" );

function ENT:Draw()

	local owner = self:GetNWEntity( "Parent" );
	
	if( LocalPlayer() == owner ) then return; end

	if( not owner or not owner:IsValid() or not owner:Alive() ) then return; end

	if( self:GetModel() == "models/eltaco/backpack.mdl" ) then

		local attachment = owner:LookupBone( "ValveBiped.Bip01_Spine2" );
		local pos, ang = owner:GetBonePosition( attachment );

		local x = ang:Up() * -2.94;
		local y = ang:Right() * 2.21;
		local z = ang:Forward() * 14;

		ang:RotateAroundAxis( ang:Forward(), 90 );
		ang:RotateAroundAxis( ang:Right(), 82 );
		ang:RotateAroundAxis( ang:Up(), -180 );
		
		self:SetPos( pos + x + y + z + owner:GetVelocity() * .025 );
		self:SetAngles( ang );
		
	elseif( self:GetModel() == "models/items/healthkit.mdl" ) then
		
		local attachment = owner:LookupAttachment( "anim_attachment_RH" );
		attachment = owner:GetAttachment( attachment );
	
		self:SetPos( attachment.Pos );
		self:SetAngles( attachment.Ang );	
		
	else
	
		local attachment = owner:LookupAttachment( "anim_attachment_RH" );
		attachment = owner:GetAttachment( attachment );
	
		self:SetPos( attachment.Pos );
		self:SetAngles( owner:GetAngles() );
		
	end
	
	

	self:DrawModel();
	
end